package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.EngineerLevel;
import com.shrcl.engineerprocess.domain.TSCPhase;
import com.shrcl.engineerprocess.domain.TSCWorkLoadType;
import com.shrcl.engineerprocess.domain.impl.EngineerLevelImpl;
import com.shrcl.engineerprocess.domain.impl.TSCPhaseImpl;
import com.shrcl.engineerprocess.domain.proxy.TSCWorkLoadTypeProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("TSCWORKLOADTYPE_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "tscworkloadtype")
public class TSCWorkLoadTypeImpl extends BaseModelObject implements TSCWorkLoadType {
  public TSCWorkLoadTypeImpl() {
    super();
  }
  
  @JoinColumn(name = "phase_id")
  @ManyToOne(targetEntity = TSCPhaseImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private TSCPhase phase;
  
  public TSCPhase getPhase() {
    return this.phase;
  }
  
  public TSCWorkLoadType setPhase(final TSCPhase phase) {
    this.phase = phase;
    return this;			
    
  }
  
  @JoinColumn(name = "engineerLevel_id")
  @ManyToOne(targetEntity = EngineerLevelImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private EngineerLevel engineerLevel;
  
  public EngineerLevel getEngineerLevel() {
    return this.engineerLevel;
  }
  
  public TSCWorkLoadType setEngineerLevel(final EngineerLevel engineerLevel) {
    this.engineerLevel = engineerLevel;
    return this;			
    
  }
  
  private String codeid;
  
  public String getCodeid() {
    return this.codeid;
  }
  
  public TSCWorkLoadType setCodeid(final String codeid) {
    this.codeid = codeid;
    return this;			
    
  }
  
  private String name;
  
  public String getName() {
    return this.name;
  }
  
  public TSCWorkLoadType setName(final String name) {
    this.name = name;
    return this;			
    
  }
  
  public String getEntityName() {
    String _name = this.phase.getName();
    String _plus = (_name + " ");
    String _plus_1 = (_plus + this.name);
    return _plus_1;
  }
  
  public static TSCWorkLoadType create(final IObjectFactory objectFactory) {
    com.shrcl.engineerprocess.domain.TSCWorkLoadType tSCWorkLoadType = new com.shrcl.engineerprocess.domain.impl.TSCWorkLoadTypeImpl(
    );
    objectFactory.create(tSCWorkLoadType);
    return tSCWorkLoadType;			
    
  }
  
  public static TSCWorkLoadType createTSCWorkLoadTypeImpl(final IObjectFactory objectFactory, final Procedure1<TSCWorkLoadType> init) {
    com.shrcl.engineerprocess.domain.TSCWorkLoadType tSCWorkLoadType = new com.shrcl.engineerprocess.domain.impl.TSCWorkLoadTypeImpl(
    );
    objectFactory.create(tSCWorkLoadType);
    init.apply(tSCWorkLoadType);
    
    return tSCWorkLoadType;			
    
  }
  
  public TSCWorkLoadTypeProxy toProxy() {
    com.shrcl.engineerprocess.domain.proxy.TSCWorkLoadTypeProxy proxy = new com.shrcl.engineerprocess.domain.proxy.TSCWorkLoadTypeProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
